package com.dragon.repository.domain.dto;

import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.Deliver;
import com.dragon.repository.entity.DeliverProducts;
import com.dragon.repository.entity.OtherFile;
import com.dragon.repository.entity.WorkflowJson;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.ALWAYS)
public class DeliverDTO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "送货名称")
    private String name;

    @ApiModelProperty(value = "配送人id")
    private Integer deliveryId;

    @ApiModelProperty(value = "客户id")
    private Integer customerId;

    @ApiModelProperty(value = "退货单id")
    private Integer rejectedId;

    @ApiModelProperty(value = "生产单号id")
    private Integer produceId;

    @ApiModelProperty(value = "合同id")
    private Integer contractId;

    @ApiModelProperty(value = "用户id")
    private Integer adminId;

    @ApiModelProperty(value = "部门id")
    private Integer departmentId;

    @ApiModelProperty(value = "收货地址")
    private String address;

    @ApiModelProperty(value = "送货类型")
    private Integer deliverType;

    @ApiModelProperty(value = "司机")
    private String driverName;

    @ApiModelProperty(value = "车牌号")
    private String carNumber;

    @ApiModelProperty(value = "货运单号或者快递单号")
    private String orderNumber;

    @ApiModelProperty(value = "送货状态：0未发货 1已发货 2已收货")
    private Integer type;

    @ApiModelProperty(value = "状态：0 待审核 1审核通过 2审核不通过 3作废 4删除")
    private Integer status;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "0生产单 1生产单(重做) 2生产单维修")
    private Integer source;

    @ApiModelProperty(value = "配送时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date deliverTime;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "确认收货时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date deliveryTime;

    @ApiModelProperty(value = "生产单名称")
    private String produceName;

    @ApiModelProperty(value = "送货人名称")
    private String deliveryName;

    @ApiModelProperty(value = "合同名称")
    private String contractName;

    @ApiModelProperty(value = "申请人名称")
    private String applicantName;

    @ApiModelProperty(value = "工作流json")
    private List<WorkflowJson> workflowJsonList;

    @ApiModelProperty(value = "附件列表")
    private List<OtherFile> otherFileList;

    @ApiModelProperty(value = "送货产品列表")
    private List<DeliverProducts> deliverProducts;



    public DeliverDTO() {}

    public DeliverDTO(Deliver entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static DeliverDTO convert(Deliver entity) {
        return new DeliverDTO(entity);
    }

    public static List<DeliverDTO> convertList(List<Deliver> list) {
        List<DeliverDTO> resultList = new ArrayList<>();
        for (Deliver entity : list) {
            resultList.add(new DeliverDTO(entity));
        }
        return resultList;
    }}
